<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta name="viewport"
		  content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

	<title>购物车页面</title>

	<link href="/static/home/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css"/>
	<link href="/static/home/basic/css/demo.css" rel="stylesheet" type="text/css"/>
	<link href="/static/home/css/cartstyle.css" rel="stylesheet" type="text/css"/>
	<link href="/static/home/css/optstyle.css" rel="stylesheet" type="text/css"/>

	<script type="text/javascript" src="/static/home/js/jquery.js"></script>
	<script src="/static/home/js/jquery-1.11.3.min.js"></script>

</head>

<body>

<!--顶部导航条 -->
<div class="am-container header">
	<!--<ul class="message-l">
		<div class="topMessage">
			<div class="menu-hd">
				<a href="#" target="_top" class="h">亲，请登录</a>
				<a href="#" target="_top">免费注册</a>
			</div>
		</div>
	</ul>-->
	<ul class="message-r">
		<div class="topMessage home">
			<div class="menu-hd"><a href="/index/index/index" target="_top" class="h">商城首页</a></div>
		</div>
		<div class="topMessage my-shangcheng">
			<div class="menu-hd MyShangcheng"><a href="/index/person/index" target="_top"><i
				class="am-icon-user am-icon-fw"></i>个人中心</a></div>
		</div>
		<div class="topMessage mini-cart">
			<div class="menu-hd"><a id="mc-menu-hd" href="/index/person/shopcart" target="_top"><i
				class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum"
																					  class="h"></strong></a></div>
		</div>
		<div class="topMessage favorite">
			<div class="menu-hd"><a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a>
			</div>
		</div>
		<a href="/index/index/loginout" style="float: right; margin-top: 8px"> 退出</a>
	</ul>
</div>

<!--悬浮搜索框-->

<div class="nav white">
	<div class="logo"><img src="/static/home/images/logo.png"/></div>
	<div class="logoBig">
		<li><img src="/static/home/images/logobig.png"/></li>
	</div>

	<div class="search-bar pr">
		<a name="index_none_header_sysc" href="#"></a>
		<form>
			<input id="searchInput" name="index_none_header_sysc" type="text" placeholder="搜索" autocomplete="off">
			<input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="submit">
		</form>
	</div>
</div>

<div class="clear"></div>

<!--购物车 -->
<form action="/index/person/pay" method="post">
	<div class="concent">
		<div id="cartTable">
			<div class="cart-table-th">
				<div class="wp">
					<div class="th th-chk">
						<div id="J_SelectAll1" class="select-all J_SelectAll">

						</div>
					</div>
					<div class="th th-item">
						<div class="td-inner">商品信息</div>
					</div>
					<div class="th th-price">
						<div class="td-inner">单价</div>
					</div>
					<div class="th th-amount">
						<div class="td-inner">数量</div>
					</div>
					<div class="th th-sum">
						<div class="td-inner">金额</div>
					</div>
					<div class="th th-op">
						<div class="td-inner">操作</div>
					</div>
				</div>
			</div>
			<div class="clear"></div>

			<tr class="item-list">
				<div class="bundle  bundle-last ">
					<!--<div class="bundle-hd">
						<div class="bd-promos">
							<div class="bd-has-promo">已享优惠:<span class="bd-has-promo-content">省￥19.50</span>&nbsp;&nbsp;</div>
							<div class="act-promo">
								<a href="#" target="_blank">第二支半价，第三支免费<span class="gt">&gt;&gt;</span></a>
							</div>
							<span class="list-change theme-login">编辑</span>
						</div>
					</div>
					<div class="clear"></div>-->
					<div class="bundle-main">
						{if isset($buyData)}
						{foreach $buyData as $val}
						{if isset($goods)}
						{foreach $goods as $goodVal}
						{if $val['goods_id'] == $goodVal['goods_id']}
						<ul class="item-content clearfix">
							<li class="td td-chk">
								<div class="cart-checkbox ">
									<input class="check" id="J_CheckBox_170037950254" name="items[]"
										   value="{$val['goods_id']}" type="checkbox">
									<label for="J_CheckBox_170037950254"></label>
								</div>
							</li>
							<li class="td td-item">
								<div class="item-pic">
									<a href="/index/index/introduction?gid={$val['goods_id']}" target="_blank"
									   data-title="{$goodVal['goods_name']}" class="J_MakePoint"
									   data-point="tbcart.8.12">
										<img src="/{$goodVal['small_logo']}" class="itempic J_ItemImg"></a>
									<input type="hidden" name="pic[{$val['goods_id']}]"
										   value="{$goodVal['small_logo']}">
								</div>
								<div class="item-info">
									<div class="item-basic-info">
										<a href="/index/index/introduction?gid={$val['goods_id']}" target="_blank"
										   title="{$goodVal['goods_name']}" class="item-title J_MakePoint"
										   data-point="tbcart.8.11">{$goodVal['goods_name']}</a>
										<input type="hidden" name="name[{$val['goods_id']}]"
											   value="{$goodVal['goods_name']}">
									</div>
								</div>
							</li>
							<li class="td td-info">
								<div class="item-props item-props-can">
									{if isset($attr)}
									{foreach $attr as $detail}
									{if $detail['attr_id'] == $val['attr_id']}
									<span class="sku-line">口味：{$detail['attr_name']}</span>
									<input type="hidden" name="taste[{$val['goods_id']}]"
										   value="{$detail['attr_name']}">
									{/if}
									{/foreach}
									{/if}
									<i class="theme-login am-icon-sort-desc"></i>
								</div>
							</li>
							<li class="td td-price">
								<div class="item-price price-promo-promo">
									<div class="price-content">
										<div class="price-line">
											<em class="price-original">{$goodVal['market_price']}</em>
										</div>
										<div class="price-line">
											<em class="J_Price price-now goodsprice"
												tabindex="0">{$goodVal['shop_price']}</em>
											<input type="hidden" name="goodPrice[{$val['goods_id']}]"
												   value="{$goodVal['shop_price']}">
										</div>
									</div>
								</div>
							</li>
							<li class="td td-amount">
								<div class="amount-wrapper ">
									<div class="item-amount ">
										<div class="sl">
											<input class="min am-btn jian" name="" type="button" value="-"/>
											<input class="text_box" name="num[{$val['goods_id']}]" type="text"
												   value="{$val['buy_num']}"
												   style="width:30px;" readonly/>
											<input class="add am-btn" name="" type="button" value="+"/>
										</div>
									</div>
								</div>
							</li>
							<li class="td td-sum">
								<div class="td-inner">
									<em tabindex="0" class="J_ItemSum number single">{$goodVal['shop_price'] *
										$val['buy_num']}</em>
								</div>
							</li>
							<li class="td td-op">
								<div class="td-inner">
									<a title="移入收藏夹" class="btn-fav" href="#">
										移入收藏夹</a>
									<a href="javascript:;" data-point-url="#" class="delete">
										删除</a>
								</div>
							</li>
						</ul>
						{/if}
						{/foreach}
						{/if}
						{/foreach}
						{/if}

					</div>
				</div>
			</tr>
		</div>
		<div class="clear"></div>

		<div class="float-bar-wrapper">
			<div id="J_SelectAll2" class="select-all J_SelectAll">
				<div class="cart-checkbox">
					<input class="check-all check han" id="J_SelectAllCbx2" name="select-all" value="true"
						   type="checkbox">
					<label for="J_SelectAllCbx2"></label>
				</div>
				<span>全选</span>
			</div>
			<div class="operations">
				<a href="#" hidefocus="true" class="deleteAll">删除</a>
				<a href="#" hidefocus="true" class="J_BatchFav">移入收藏夹</a>
			</div>
			<div class="float-bar-right">
				<div class="amount-sum">
					<span class="txt">已选商品</span>
					<em id="J_SelectedItemsCount">0</em><span class="txt">件</span>
					<div class="arrow-box">
						<span class="selected-items-arrow"></span>
						<span class="arrow"></span>
					</div>
				</div>
				<div class="price-sum">
					<span class="txt">合计:</span>
					<strong class="price">¥<em id="J_Total">0.00</em></strong>
				</div>
				<div class="btn-area">
					<input id="J_Go" class="submit-btn submit-btn-disabled"
						   style="background: orangered; border: hidden;" value="结算" type="button">
				</div>
			</div>

		</div>

		<div class="footer">
			<div class="footer-hd">
				<p>
					<a href="#">恒望科技</a>
					<b>|</b>
					<a href="/index/index/index">商城首页</a>
					<b>|</b>
					<a href="#">支付宝</a>
					<b>|</b>
					<a href="#">物流</a>
				</p>
			</div>
			<div class="footer-bd">
				<p>
					<a href="#">关于恒望</a>
					<a href="#">合作伙伴</a>
					<a href="#">联系我们</a>
					<a href="#">网站地图</a>
					<em>© 2015-2025 Hengwang.com 版权所有</em>
				</p>
			</div>
		</div>

	</div>
</form>
<!--操作页面-->

<!--<div class="theme-popover-mask"></div>

<div class="theme-popover">
	<div class="theme-span"></div>
	<div class="theme-poptit h-title">
		<a href="javascript:;" title="关闭" class="close">×</a>
	</div>
	<div class="theme-popbod dform">
		<form class="theme-signin" name="loginform" action="" method="post">

			<div class="theme-signin-left">

				<li class="theme-options">
					<div class="cart-title">颜色：</div>
					<ul>
						<li class="sku-line selected">12#川南玛瑙<i></i></li>
						<li class="sku-line">10#蜜橘色+17#樱花粉<i></i></li>
					</ul>
				</li>
				<li class="theme-options">
					<div class="cart-title">包装：</div>
					<ul>
						<li class="sku-line selected">包装：裸装<i></i></li>
						<li class="sku-line">两支手袋装（送彩带）<i></i></li>
					</ul>
				</li>
				<div class="theme-options">
					<div class="cart-title number">数量</div>
					<dd>
						<input class="min am-btn am-btn-default" name="" type="button" value="-" />
						<input class="text_box" name="" type="text" value="1" style="width:30px;" />
						<input class="add am-btn am-btn-default" name="" type="button" value="+" />
						<span  class="tb-hidden">库存<span class="stock">1000</span>件</span>
					</dd>

				</div>
				<div class="clear"></div>
				<div class="btn-op">
					<div class="btn am-btn am-btn-warning">确认</div>
					<div class="btn close am-btn am-btn-warning">取消</div>
				</div>

			</div>
			<div class="theme-signin-right">
				<div class="img-info">
					<img src="/static/home/images/kouhong.jpg_80x80.jpg" />
				</div>
				<div class="text-info">
					<span class="J_Price price-now">¥39.00</span>
					<span id="Stock" class="tb-hidden">库存<span class="stock">1000</span>件</span>
				</div>
			</div>

		</form>
	</div>
</div>-->
<!--引导 -->
<!--<div class="navCir">
	<li><a href="/index/index/index"><i class="am-icon-home "></i>首页</a></li>
	<li><a href="/index/index/sort"><i class="am-icon-list"></i>分类</a></li>
	<li class="active"><a href="/index/person/shopcart"><i class="am-icon-shopping-basket"></i>购物车</a></li>
	<li><a href="/index/person/index"><i class="am-icon-user"></i>我的</a></li>
</div>-->
</body>
<script>
    $(function () {
        $('#J_Go').click(function () {
            if ($("input[name='items[]']:checked").length != 0) {
                $(this).attr('type', 'submit')
            } else {
                alert('请选择要购买的商品');
            }
        });


        //减号功能-------------------------------------------
        $('.jian').click(function () {
            var num = $(this).next().val() - 1;
            if (num >= 0) {
                //单个信息总价减的展示
                var price = accMul(num, $(this).parent().parent().parent().parent().prev().find('.price-now').text());
                $(this).parent().parent().parent().parent().next().children().children().text(price);

                if ($(this).parent().parent().parent().parent().parent().find('.check').is(':checked')) {
                    var total = parseFloat($('#J_Total').text());
                    var delPrice = $(this).parent().parent().parent().parent().prev().find('.price-now').text();
                    $('#J_Total').text(accSub(total, delPrice));
                }
            }
        });

        //加号功能
        $('.add').click(function () {
            //单个商品加的总价展示
            var singlePrice = $(this).parent().parent().parent().parent().prev().find('.goodsprice').text();
            var numNow = parseInt($(this).prev().val()) + 1;
            var price = accMul(singlePrice, numNow);
            $(this).parent().parent().parent().parent().next().children().children().text(price);

            //选中状态下加号, 总价的展示
            if ($(this).parent().parent().parent().parent().parent().find('.check').is(':checked')) {
                var total = parseFloat($('#J_Total').text());
                var delPrice = $(this).parent().parent().parent().parent().prev().find('.price-now').text();
                $('#J_Total').text(accAdd(total, delPrice));
            }
        });


        //判断多选框(选中与取消
        $('input[type=checkbox]').click(function () {


            if ($(this).is(':checked')) {
                var total = parseFloat($(this).parent().parent().parent().find('.single').text());
                var old = parseFloat($('#J_Total').text());
                $('#J_Total').text(accAdd(total, old));


                //这个是什么鬼哦, 兼容性问题...o.o
                if ($("input[name='items[]']:checked").length == $("input[name='items[]']").length) {
                    $('.han').attr('checked', true);
                }
            }
            else {

                var total = parseFloat($(this).parent().parent().parent().find('.single').text());
                var old = parseFloat($('#J_Total').text());
                $('#J_Total').text(accSub(old, total));

                $('#J_SelectAllCbx2').attr('checked', false);
            }
        });

        //全选
        $('#J_SelectAllCbx2').click(function () {
            if ($("#J_SelectAllCbx2").prop("checked")) {

                $("input[name='items[]']").prop("checked", true);
                var allPrice = null;
                $('.J_ItemSum').each(function () {
                    allPrice = accAdd($(this).text(), allPrice);
                });
                $('#J_Total').text(allPrice);
            } else {
                $("input[name='items[]']").prop("checked", false);
                $('#J_Total').text('0');
            }
        });

        //精确的减法
        function accSub(arg1, arg2) {
            if (isNaN(arg1)) {
                arg1 = 0;
            }
            if (isNaN(arg2)) {
                arg2 = 0;
            }
            arg1 = Number(arg1);
            arg2 = Number(arg2);

            var r1, r2, m, n;
            try {
                r1 = arg1.toString().split(".")[1].length;
            }
            catch (e) {
                r1 = 0;
            }
            try {
                r2 = arg2.toString().split(".")[1].length;
            }
            catch (e) {
                r2 = 0;
            }
            m = Math.pow(10, Math.max(r1, r2)); //last modify by deeka //动态控制精度长度
            n = (r1 >= r2) ? r1 : r2;
            return ((arg1 * m - arg2 * m) / m).toFixed(n);
        }

        // 给Number类型增加一个mul方法，调用起来更加方便。
        Number.prototype.sub = function (arg) {
            return accSub(this, arg);
        };

        //精确的加法
        function accAdd(arg1, arg2) {
            if (isNaN(arg1)) {
                arg1 = 0;
            }
            if (isNaN(arg2)) {
                arg2 = 0;
            }
            arg1 = Number(arg1);
            arg2 = Number(arg2);
            var r1, r2, m, c;
            try {
                r1 = arg1.toString().split(".")[1].length;
            }
            catch (e) {
                r1 = 0;
            }
            try {
                r2 = arg2.toString().split(".")[1].length;
            }
            catch (e) {
                r2 = 0;
            }
            c = Math.abs(r1 - r2);
            m = Math.pow(10, Math.max(r1, r2));
            if (c > 0) {
                var cm = Math.pow(10, c);
                if (r1 > r2) {
                    arg1 = Number(arg1.toString().replace(".", ""));
                    arg2 = Number(arg2.toString().replace(".", "")) * cm;
                } else {
                    arg1 = Number(arg1.toString().replace(".", "")) * cm;
                    arg2 = Number(arg2.toString().replace(".", ""));
                }
            } else {
                arg1 = Number(arg1.toString().replace(".", ""));
                arg2 = Number(arg2.toString().replace(".", ""));
            }
            return (arg1 + arg2) / m;
        }

        //乘法...
        function accMul(arg1, arg2) {
            if (isNaN(arg1)) {
                arg1 = 0;
            }
            if (isNaN(arg2)) {
                arg2 = 0;
            }
            arg1 = Number(arg1);
            arg2 = Number(arg2);

            var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
            try {
                m += s1.split(".")[1].length;
            }
            catch (e) {
            }
            try {
                m += s2.split(".")[1].length;
            }
            catch (e) {
            }
            return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
        }
    })
    ;

</script>


</html>